package com.gxy.learn.design.model.behaviour.interpreter;

/**
 * @description:
 * @author: gaoxueyong
 * @Date: 2022/11/9 10:51
 */
public class Variable extends AbstractExpression{

    private String name;

    public Variable(String name) {
        this.name = name;
    }

    /**
     * 解释器
     *
     * @param context
     * @return void
     * @Author gaoxueyong
     * @Date 10:50 上午 2022/11/9
     * @Param [context]
     */
    @Override
    int interprete(Context context) {
       return context.getValue(this);
    }

    @Override
    public String toString() {
        return name;
    }
}
